execute as @n[tag=inputClicked,type=interaction,distance=..10] on target run tag @s add clicker

execute if items entity @p[tag=clicker,distance=..200] weapon.mainhand *[custom_data~{id:"battery"},!damage~{damage:{min:200}}] if data entity @s item.components."minecraft:custom_data".guardTowerData{PowerInputEmpty:true} run function vs:system/game_ctrol/guard_tower/power/place_battery

data remove entity @n[tag=inputClicked,type=interaction,distance=..10] interaction
tag @n[tag=inputClicked,type=interaction,distance=..10] remove inputClicked
tag @p[tag=clicker,distance=..200] remove clicker